<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>

<head>
    <title>服务记录</title>
</head>

<body>

<div id="jy wrapper">
    <div class="gray-bg">
        <div class="jy-nav-box">
            <ul class="navbar-nav">
                <li><span>${teamName}</span><a class="switch">切换团队</a></li>
                <li><a href="/medical/sign/list" >居民管理</a></li>
                <li><a href="/medical/record/list" class="active">服务记录</a></li>
                <li><a href="/medical/statistic/list">签约统计</a></li>
            </ul>
            <input type="hidden" id="idcard" value="${idcard}">
            <div class="dropdown-menu">
                <ul id="teamSwitch">
                </ul>
            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox">
                        <div class="ibox-content">
                            <div class="search-area">
                                <form role="form" class="form-inline" id="queryform">
                                    <input class="form-control  form-filter" type="hidden" id="teamId" name="teamId" value="${teamId}">
                                    <label for="type">
                                        <select class="form-control  form-filter" name="type" id="type">
                                            <option value="1">姓名</option>
                                            <option value="2">手机号</option>
                                        </select>
                                    </label>
                                    <label for="keyword">
                                        <input type="input" placeholder="请输入内容" name="keyword" id="keyword"
                                               class="form-control form-filter">
                                    </label>
                                    <button class="btn" type="button" onclick="submitFilter()"> 查询</button>
                                    <button class="btn" datatable-clear type="button"> 清除</button>
                                </form>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover dataTables" id="data-table" style="word-break:break-all;"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</div>

<%--<script src="${ctx}/static/inspinia/js/plugins/chosen/chosen.jquery.js"></script>--%>
<script src="${ctx}/static/inspinia/js/plugins/layer/layer.js"></script>
<!-- Page-Level Scripts -->
<script>
    $(document).ready(function () {

        var setting = {
            "ajax": {
                "url": "${ctx}/medical/record/list",
                "type": "POST"
            },
            "columns": [
                {"title": "服务对象", "data": "ename", "width": "10%", "orderable": true},
                {"title": "手机号", "data": "emobile", "width": "10%", "orderable": false},
                {"title": "服务项", "data": "itemTitle", "width": "14%", "orderable": false},
                {"title": "服务包", "data": "packageTitle", "width": "12%", "orderable": false},
                {"title": "服务人", "data": "servantName", "width": "8%", "orderable": false},
                {"title": "服务时间", "data": "createTime", "width": "16%", "orderable": false},
                {"title": "服务说明", "data": "details", "width": "20%", "orderable": false},
                {"title": "操作", "data": null, "width": "10%", "orderable": false},
            ],
            "columnDefs": [
                {
                    "targets": 7,
                    "render": function (data, type, row, meta) {
                        return "<a class='btn-xs default btn-editable' href='javascript:detail("+data.id+");' data-id='"+data.id+"'>详情</a>";
                    },
                    "orderable": false
                }
            ],
            "order": [
                [5, "desc"]
            ]
        };
        /* Init DataTables */
        $('#data-table').DataTable(ehconfig.get_datatable_config(setting));
        submitFilter = function () {
            $('#data-table').DataTable().draw();
        }
    });

    function detail(recordId) {
        var url = '${ctx}/medical/record/detail?id='+recordId;
        layer.open({
            type: 2,
            title: "服务详情",
            shadeClose: true,
            shade: 0.8,
            area: ['780px', '450px'],
            content: url
        });
    }
    var switch_flag = true;
    $(function () {
        $("#data-table").on("dblclick","tr",function(){
            var recordId = $(this).children("td:last-child").children("a").attr("data-id");
            if(recordId){
                detail(recordId);
            }
        })
        //下拉菜单
        $(".switch").click(function() {
            $(".dropdown-menu").css("display", "block");
            var idcard = $('#idcard').val();
            if(switch_flag){
                switchTeam(idcard);
                switch_flag = false;
            }
        });
        $(".dropdown-menu li").click(function() {
            $(".dropdown-menu").css("display", "none");
        });
    });
    function switchTeam(idcard) {
        $.ajax({
            method: "POST",
            url: "${ctx}/medical/team/list_team",
            dataType: "json",
            data: {
                idcard:idcard
            },
            async: false,
            success: function(res) {
                var teamList = res.data;
                if(teamList){
                    for(var i=0;i<teamList.length;i++){
                        $('#teamSwitch').append('<li><a href="/medical/team/switch?id='+teamList[i].teamId+'" >'+teamList[i].teamName+'</a></li>');
                    }
                }
            }
        });
    }
</script>

</body>

</html>
